import Vue from 'vue'
import VueRouter from 'vue-router'
const Home = () =>import("views/home/Home")
const Profile = () =>import("views/profile/Profile")
const Classify = () =>import("views/classify/Classify")
const Shopcart = () =>import("views/shopcart/Shopcart")
Vue.use(VueRouter)

export default new VueRouter({
  routes: [
    {
      path: "",
      redirect: "/home"
    },
    {
      path: "/home",
      component: Home
    },
    {
      path: "/classify",
      component: Classify
    },
    {
      path: "/shopcart",
      component: Shopcart
    },
    {
      path: "/profile",
      component: Profile
    }
  ],
  mode: "history"
})
//解决路由重复点击带来的报错问题
const originalReplace = VueRouter.prototype.replace;
VueRouter.prototype.replace = function replace(location) {
  return originalReplace.call(this, location).catch(err => err);
};
